<?php

namespace app\admin\validate;


class AdminValidate extends BaseValidate
{
    public $rule = [
        'group_id' => 'require',
        'username' => 'require|regex:/^[a-zA-Z0-9_]{4,16}$/',
        'password' => 'require|regex:/(?=.*[a-z])(?=.*\d)(?=.*[#@!~%^&*])[a-z\d#@!~%^&*]{8,16}/i',
        'phone' => 'regex:/^1[0-9]{10}/',
        'email' => 'email',
        'status' => 'in:enable,disable',
    ];
    public $message = [
        'group_id.require' => '请选择权限组',
        'username.require' => '请填写用户名',
        'username.regex' => '用户名不符合规范，含字母、数字、下划线，4~16位长度',
        'password.require' => '请填写密码',
        'password.regex' => '密码不符合规范，须包含:字母、数字、特殊字符，8~16位长度',
        'phone.regex' => '手机号码不符合规范',
        'email' => '邮箱格式错误',
        'status' => '状态值错误',
    ];
    public $scene = [
        'create' => ['group_id', 'username', 'password', 'phone', 'email', 'status'],
        'update' => ['id', 'group_id', 'username', 'phone', 'email', 'status'],
        'changePassword' => ['id', 'password'],
        'login' => ['username', 'password'],
    ];
}